﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using BookTransactionControllers.Connection;
using BookTransactionControllers.Services_Impl;

public partial class Views_Login : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected void btnLogin_Click1(object sender, EventArgs e)
    {
        UserManagerImpl usManager = new UserManagerImpl();
        String Email = txtEmail.Text;
        String Password = txtPassword.Text;
        String[] infoUser = usManager.CheckLogin(Email, Password);
        if (infoUser == null)
        {
            lbMessage.Text = "Make sure your Email or Password is Valid.";
        }
        else
        {
            if (chkRemember.Checked)
            {
                HttpCookie ckLogin = new HttpCookie("Login");
                ckLogin.Values["UserID"] = infoUser[0];
                ckLogin.Values["FullName"] = infoUser[1];
                Response.Cookies.Add(ckLogin);
                Session.Add("UserID", infoUser[0]);
            }
            Response.Redirect("Home.aspx");
        }
    }
}